﻿<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>通知管理</title>
    @Html.Partial("~/Views/Share/PublicHeader.cshtml")
</head>
<body>
    @Html.Partial("~/Views/Share/PublicTopNav4Teacher.cshtml")
    <div class="container">
        <div class="row">
            <h1 class="topTitle-h1">
                @ViewData["CourseName"]<br>
            <small>广州中医药大学康复治疗微课程网络学习平台</small>
        </h1>
    </div>
</div>
@*导航菜单*@
@Html.Partial("~/Views/Share/PublicTeacherNaviMenu.cshtml", 5)
<div class="container mainwrap">
    <div class="row">
        <div class="col-xs-2">
            <div class="dropdown theme-dropdown clearfix">
                <a id="dropdownMenu1" href="#" role="button" class="sr-only dropdown-toggle" data-toggle="dropdown">Dropdown <span class="caret"></span></a>
                <ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1">
                    <li class="active" role="presentation">
                        <a role="menuitem" tabindex="-1" href="javascript:void(0)">
                            <span class="glyphicon glyphicon-cog"></span>通知列表
                        </a>
                    </li>
                    <li role="presentation" class="divider"></li>
                    <li role="presentation">
                        <a role="menuitem" tabindex="-1" href="@Url.Action("AnnounceInfoAdd", "Announce")?CourseId=@ViewData["CourseId"]">
                            <span class="glyphicon glyphicon-plus"></span>通知新增
                        </a>
                    </li>
                </ul>
            </div>
        </div>
        <div class="col-xs-10">
            <div class="panel panel-default mainwrap-part">
                <div class="panel-heading">
                    <h3 class="panel-title">
                        <ol class="breadcrumb">
                            <li>通知管理</li>
                            <li class="active">通知列表</li>
                        </ol>
                    </h3>
                </div>
                <div class="panel-body">
                    <div class="row">
                        <form class="form-horizontal" role="form">
                            <div class="form-group">
                                <div class="col-xs-4">
                                    <input type="text" class="form-control" id="noticeTitle" placeholder="请输入标题">
                                </div>
                                <div class="col-xs-2">
                                    <select class="form-control" id="noticeState">
                                        <option>是否发布</option>
                                        <option value="false">否</option>
                                        <option value="true">是</option>
                                    </select>
                                </div>
                                <div class=" col-xs-2">
                                    <button type="button" onclick="getList(1)" class="btn btn-success"><span class="glyphicon glyphicon-search"></span>搜索</button>
                                </div>
                            </div>
                        </form>
                    </div>
                    <div class="row">
                        <table class="table table-bordered tb1 table-striped table-hover">
                            <thead>
                                <tr>
                                    <th>标题</th>
                                    <th>创建人</th>
                                    <th>创建时间</th>
                                    <th>是否停用</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody id="tbody"></tbody>
                        </table>
                    </div>
                    <div class="row clearfix well d-page">
                        <div id="PagInfo" class="pull-left sum">
                        </div>
                        <div class="clearfix pull-right">
                            <ul id="PageTool" class="pagination"></ul>
                        </div>
                    </div>

                </div>
            </div>
        </div>
    </div>
</div>
@Html.Partial("~/Views/Share/PublicFooter.cshtml")
@Html.Partial("~/Views/Share/PublicCommonJs.cshtml")
<script>
    var tbody = $("#tbody");
    var options = false;
    var _state = false;
    var _courseId = "@ViewData["CourseId"]";
    function getList(pageNo) {
        var _title = $("#noticeTitle").val();
        var _isStop = $("#noticeState").val();
        $("#PagInfo").html("");
        $("#PageTool").html("");

        $.easyPost("/Announce/GetAnnounceInfoList", { "PageNO": pageNo, "PageSize": "10", "CourseId": _courseId, "Title": _title, "IsStop": _isStop },
           function (data) {
               if (!data.result) {
                   alert(data.message);
                   return;
               }
               var _html = '';
               if (data.rows.length > 0) {
                   $(".d-page").show();

                   var _row = data.rows,
                       _rowL = _row.length;
                   options = {
                       totalPages: data.totalPage,
                       total: data.total,
                       currentPage: pageNo,
                       onPageClicked: function (event, originalEvent, type, page) {
                           getList(page);
                       }
                   }
                   initialPaginator(options, "PageTool", "PagInfo");

                   for (var i = 0; i < _rowL; i++) {
                       var item = _row[i];
                       var _date = item.CreateTime.toString().replace(/\//g, "");
                       var time = eval('new ' + _date);
                       var isStop;
                       if (item.IsStop) {
                           isStop = '是';
                       }
                       else {
                           isStop = '否';
                       }
                       _html += "<tr>";
                       _html += "<td>" + item.Title + "</td>";
                       _html += "<td>" + item.Creator + "</td>";
                       _html += "<td>" + time.format('yyyy-MM-dd') + "</td>";
                       _html += "<td>" + isStop + "</td>";
                       _html += "<td>";
                       _html += "<a href='javascript:void(0)' onclick='statusChange(\"" + item.Id + "\")' class='operate'><span class='glyphicon glyphicon-stop'></span> " + (item.IsStop ? "启用" : "停用") + "</a>";
                       _html += "<a href='/Announce/AnnounceInfoEdit?Id=" + item.Id + "&CourseId="+item.CourseId+"' class='operate'><span class='glyphicon glyphicon-pencil'></span> 编辑</a>";
                       _html += "</td>";
                       _html += "</tr>";
                   }
               }
               else {
                   _html = "<tr><td colspan='5' align='center'>暂无内容!</tr>";
                   $(".d-page").hide();
               }
               tbody.html(_html);
           }, "json");
    }


    function statusChange(id) {
        $.easyPost("/Announce/AnnounceInfoStatusChange", { "Id": id },
          function (data) {
              if (!data.result) {
                  alert(data.message);
                  return;
              }
              if (!!window.location.hash) {
                  var _hash = window.location.hash.substr(1);
                  getList(_hash);
              } else {
                  getList(1);
              }
          }, "json");
    }


    if (!!window.location.hash) {
        var _hash = window.location.hash.substr(1);
        getList(_hash);
    } else {
        getList(1);
    }


</script>
</body>
</html>

